#include "show_score.h"
#include "ui_show_score.h"
#include <QDebug>
Show_Score::Show_Score(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Show_Score)
{
    ui->setupUi(this);
}

Show_Score::~Show_Score()
{
    delete ui;
}

void Show_Score::getScore(QString year, QString type , QString major, QString status)
{
    qDebug()<<year<<type<<major<<status;

    Show_ScoreModel = new QSqlTableModel;
    Show_ScoreModel->setTable("User_Plan");
    Show_ScoreModel->setEditStrategy(QSqlTableModel::OnManualSubmit);

    Show_ScoreModel->setFilter(QObject::tr("type='%1' and major = '%2' and year = '%3' and status = '%4'").arg(type)
                           .arg(major).arg(year).arg(status));

    Show_ScoreModel->select();
    Show_ScoreModel->setHeaderData(0,Qt::Horizontal,tr("id"));
    Show_ScoreModel->setHeaderData(1,Qt::Horizontal,tr("name"));
    Show_ScoreModel->setHeaderData(2,Qt::Horizontal,tr("job_number"));
    Show_ScoreModel->setHeaderData(3,Qt::Horizontal,tr("type"));
    Show_ScoreModel->setHeaderData(4,Qt::Horizontal,tr("major"));
    Show_ScoreModel->setHeaderData(5,Qt::Horizontal,tr("year"));
    Show_ScoreModel->setHeaderData(6,Qt::Horizontal,tr("status"));
    Show_ScoreModel->setHeaderData(7,Qt::Horizontal,tr("study_time"));
    Show_ScoreModel->setHeaderData(8,Qt::Horizontal,tr("Attendance"));
    Show_ScoreModel->setHeaderData(9,Qt::Horizontal,tr("checkscore"));
    Show_ScoreModel->setHeaderData(10,Qt::Horizontal,tr("testscore"));
    Show_ScoreModel->setHeaderData(11,Qt::Horizontal,tr("score"));


    int CheckCount = Show_ScoreModel->rowCount();

    //ui->ScoreInput_Count_2->setText(QString::number(CheckCount));

    ui->tableView->setModel(Show_ScoreModel);
    ui->tableView->hideColumn(0);
    ui->tableView->hideColumn(3);
    ui->tableView->hideColumn(4);
    ui->tableView->hideColumn(5);
    ui->tableView->hideColumn(6);
    ui->tableView->hideColumn(7);
}
